<template>
      <div class="bggray" >
        <div class="cellInfo box-shadow">
          <mt-cell style="white-space: nowrap">
            <span slot="title" class="cellTitle">
            <div class="cellName">{{college.name}}</div>
            <div class="cellTip"> <span >代码：{{college.code}}</span> </div>
            <div class="cellLabel">
              <span >{{college.sheng}}</span><span>{{college.is985}}</span><span>{{college.is211}}</span><span>{{college.schoolproperty}}</span>
            </div>
            </span>
            <img slot="icon" :src="'/'+college.logo" width="80" height="80">
          </mt-cell>
        </div>

        <mt-navbar v-model="selected">
          <mt-tab-item id="1"><span style="font-size: 16px">简介</span></mt-tab-item>
          <mt-tab-item id="2"><span style="font-size: 16px">招生章程</span></mt-tab-item>
        </mt-navbar>

        <mt-tab-container v-model="selected" >
          <mt-tab-container-item id="1">
            <div class="tabInfo">
              <h4>学校简介</h4>
              <div id="video" v-show="college.videoUrl && videoPrefix && $root.userInfo.vip_level" style="width: 100%;max-width: 600px;"></div>
              <p class="phead" v-html="college.info?(college.info.trim()):''"></p>
            </div>
            <div class="tabInfo">
              <h4>联系方式</h4>
              <p>联系方式：<span>{{college.phone}}</span></p>
              <p>院校官网：<a :href="(college.site&&college.site.indexOf('http')>-1)?college.site:('http://'+college.site)" target="_blank">{{college.site}}</a></p>
              <p>院校地址: <span>{{college.address}}</span></p>
              <p class="phead">email: <span>{{college.email}}</span></p>
            </div>
            <div class="tabInfo">
              <h4>收费方式</h4>
              <div class="phead" v-html="college.shoufei"></div>
            </div>

            <div style=" ">

            </div>
          </mt-tab-container-item>
          <mt-tab-container-item id="2">
            <div class="tabInfo">
              <h4>招生章程</h4>
              <a :href="(college.policyUrl&&college.policyUrl.indexOf('http')>-1)?college.policyUrl:('http://'+college.policyUrl)" target="_blank">{{college.policyUrl}}</a>
              <!--<div class="phead" v-html="college.join_rules"></div>-->
            </div>
          </mt-tab-container-item>
        </mt-tab-container>
      </div>
</template>
<script>
    import { Toast } from 'mint-ui';
    export default {
        name: "college",
        data(){
          return {
            selected:"1",
            videoPrefix:"",
            college:{}
          }
        },
        methods:{
          //辨别内外网
          checkNetwork: function(fn){
            let vm = this;
            checkLogin(this,function(){
              if(vm.college.videoUrl && vm.$root.userInfo&& vm.$root.userInfo.vip_level){

                vm.$root.videoServerUrl.forEach(n=>{
                    let videoPrefix = n.val;
                    vm.$http.get(videoPrefix+"/test.html",{timeout: 800}).then(resp=>{
                      console.log(resp);
                    }).catch(err=>{
                      if(err.message.indexOf("timeout")>-1){
                        Toast("视频服务"+videoPrefix+"不可访问,正在切换网络!");
                      }else{
                        vm.videoPrefix = videoPrefix;
                        fn && fn(videoPrefix);
                      }
                      console.log(err);
                    })
                })
              }
            },true);
          },
          playVideo(videoPrefix){
            let vm = this;
              var videoObject = {
                container: '#video', //容器的ID或className
                variable: 'player', //播放函数名称
                //loop: true, //播放结束是否循环播放
                autoplay: true,//是否自动播放
                // poster: 'material/poster.jpg', //封面图片
                /*preview: { //预览图片
                  file: ['material/mydream_en1800_1010_01.png', 'material/mydream_en1800_1010_02.png'],
                  scale: 2
                },*/
                //flashplayer:true,
                //live:true,
                //debug:true,
                /*video:[
                    ['http://img.ksbbs.com/asset/Mon_1703/05cacb4e02f9d9e.mp4', 'video/mp4', '中文标清', 0],
                    ['http://img.ksbbs.com/asset/Mon_1703/d0897b4e9ddd9a5.mp4', 'video/mp4', '中文高清', 0],
                    ['http://img.ksbbs.com/asset/Mon_1703/eb048d7839442d0.mp4', 'video/mp4', '英文高清', 0],
                    ['http://img.ksbbs.com/asset/Mon_1703/d30e02a5626c066.mp4', 'video/mp4', '英文超清', 0]
                ]*/
                video:[
                  [videoPrefix+this.college.videoUrl, 'video/mp4', '中文标清', 0]
                  //,['http://web.jinbanggaokao.cn/upload/video/阿里阿里.mp4', 'video/mp4', '中文标清', 0]
                ]
              };
              var player = new ckplayer(videoObject)
          }
        },
        created(){
          //window.scrollTo(0,0);
          document.documentElement.scrollTop = document.body.scrollTop = 0;
          if(this.$route.params.id){
            var vm = this;
              this.$http.get('/wx/school/'+this.$route.params.id).then((resp)=>{
                  vm.college = resp.data;
                  vm.checkNetwork(vm.playVideo);
              }
            )
          }
        },
    }
</script>
<style>
  .cellInfo .mint-cell-wrapper{
    background-image: none;
  }
</style>
<style scoped>
  .cellInfo{
    background: white;
    padding: 30px 15px;
    margin-bottom: 3px;
  }

  .cellTitle{
    margin-left: 20px;
    display: inline-block;
    vertical-align: middle;
  }
  .cellName{
    font-size: 26px;
    line-height: 42px;
  }
  .cellTip{
    font-size: 14px;color:#7f8c8d;  line-height: 22px;
  }
  .cellLabel{
    color:lightskyblue;
  }
  .cellLabel span{
    padding-right: 5px;
  }

  .tabInfo{
    background: white;padding: 10px;
    margin-top: 10px;
  }
</style>
